package com.base.api.controller.slideshow;

import com.base.log.WebLog;
import com.base.result.ResponseResult;
import com.base.self.dto.slideshow.ShowSlideshowDTO;
import com.base.self.entity.Slideshow;
import com.base.self.service.ISlideshowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Slf4j
@RequestMapping("/api/slideshow")
@Api(tags = "首页轮播图查询")
public class SlideshowApiController {

    private final ISlideshowService iSlideshowService;

    public SlideshowApiController(ISlideshowService iSlideshowService) {
        this.iSlideshowService = iSlideshowService;
    }


    @ApiOperation(value="首页轮播图查询")
    @PostMapping(value = "/showSlideshow", produces = "application/json;charset=UTF-8")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = Slideshow.class),
    })
    @Validated
    @WebLog
    public ResponseResult showSlideshow(@Valid final ShowSlideshowDTO showSlideshowDTO) {
        return iSlideshowService.showSlideshow(showSlideshowDTO);
    }
}
